import confing from "./confing.js"


let baseUrl = confing.baseUrl







   export   function  request(url, data = {}, method = 'GET') {

	let p1 = new Promise((resolve, reject) => {

		// 开启正在加载数据 loading 效果
		uni.showLoading({
			title: '正在加载中....'
		})


		uni.request({
			url: baseUrl + url,
			data,
			method,
			timeout: 2000,
			complete: () => {
				//  加载loading    关闭loading 效果

console.log('不管成功与失败都要执行')

	  // uni.hideLoading()
	  
	  setTimeout(function () {
	      uni.hideLoading();
	  }, 1000);
			

			},
			fail: (err) => {
				
				console.log('fail')
				reject(err)
				  // uni.hideLoading();

			},
			success: (res) => {
				console.log('success')
				resolve(res.data)
				  // uni.hideLoading();

			}
		})



	})


	return p1


}
